package cate.game.play.skill.passive.gem;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时，有 23% 概率使敌人缴械（降低 99% 攻击力），每次攻击最多只有一个人被缴械
 */
public class 缴械PH extends PassiveHandler {

	private int 概率;

	private int buff;

	//概率=2300&buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
	}


	private boolean addBuff;

	@Override
	public void afterOneAttack(SkillActionCtx action, long totalDamage, boolean strike, Fighter target) {
		if (addBuff) {
			return;
		}
		int i = target.buff.tryAddByTid(action, skill.owner, buff, 概率);
		if (i > 0) {
			addBuff = true;
		}
	}

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		addBuff = false;
	}
}
